<?php namespace Home\Controller; 

use Hdphp\Controller\Controller;

//测试控制器

	class LoginController extends Controller {

		public function login() {

			if (IS_POST) {
				//			获取数据
				$username = Q('post.username');
				$password = Q('post.password', '', 'md5');
				//			获取数据库所以数据
				$model = new \Common\Model\User;
				$userDate = $model -> where('username', $username) -> find();
				//			判断用户是否存在
				if (!$userDate) {
					View::error('用户不存在');
				}
				if ($userDate['password'] != $password) {
					View::error('密码错误');
				}
				//			写入session登录
				$_SESSION['uid'] = $userDate['uid'];
				View::success('登陆成功', U('Home/Index/index'));
			}
			View::make();
		}

	}
